package com.hry.store.cms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hry.store.cms.dao.UserMapper;
import com.hry.store.cms.pojo.User;
import com.hry.store.cms.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 获取所有用户信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo getAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> userList = userMapper.getAll();
        PageInfo pageInfo = new PageInfo(userList);
        return pageInfo;
    }

    /**
     * 更新用户信息
     * @param userName
     * @param userEmail
     * @param userPhone
     * @param userSign
     * @param favorite
     * @param editUserStatus
     * @return
     */
    @Override
    public int updateUserInfo(String userName, String userEmail, String userPhone, String userSign, String favorite, Integer editUserStatus) {
        User user = new User();
        user.setUserName(userName);
        user.setUserEmail(userEmail);
        user.setPhone(userPhone);
        user.setPersonSign(userSign);
        user.setFavorite(favorite);
        user.setStatus(editUserStatus);
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
